configure jersey to use jackson over json binding #795
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the current
gitlab4j-api(4.19.0), when thejersey-media-json-bindingis on the classpath, jersey will use jsonb (eclipse yasson) to deserialize the json response, because it implements theForcedAutoDiscoverableinterface and always gets registered with a higher priority.https://github.com/eclipse-ee4j/jersey/blob/master/media/json-binding/src/main/java/org/glassfish/jersey/jsonb/internal/JsonBindingAutoDiscoverable.java
https://github.com/eclipse-ee4j/jersey/blob/9dbc693eaff403e4a1b285cac77361fd96b9b694/core-common/src/main/java/org/glassfish/jersey/internal/spi/ForcedAutoDiscoverable.java
To fix this, we need to register the
JacksonFeatureto force jersey to use jackson over json binding.Context:
I use 2 plugins in jenkins: the
gitlab-pluginwhich usesjerseydirectly and thegitlab-branch-sourceplugin that usesgitlab4j-api(packaged in thegitlab-apiplugin).Since
gitlab-pluginhas been updated to use a newjersey2-apiplugin, I had strangeClassCastExceptionwithgitlab4j-apiandjersey, to fix this I'm modifying thegitlab-apiplugin to also use thejersey2-apiplugin instead of packaging its ownjerseylibs. Because thejersey2-apiplugin containsjersey-media-json-binding, it wasn't working until I made the changes to registerJacksonFeature.